package com.example.houseitemmanagebackend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.houseitemmanagebackend.entity.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 消息Mapper接口
 */
@Mapper
public interface MessageMapper extends BaseMapper<Message> {

    /**
     * 标记位置所有消息为已读
     * 
     * @param locationId 位置ID
     * @return 更新的记录数
     */
    @Update("UPDATE messages SET is_read = 1 WHERE location_id = #{locationId} AND is_read = 0")
    int markAllAsReadByLocation(@Param("locationId") Integer locationId);
}